package com.aididi.controller;

import com.aididi.config.EnviromentConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EveryController {

    @Autowired
    private Environment env;
    @Autowired
    private EnviromentConfig enviromentConfig;

    @Value("${spring.application.name}")
    private String name;


    @RequestMapping("/config/{key:.+}")
    public Object getConfig(@PathVariable String key){
        return  env.getProperty(key);
    }

    @RequestMapping("/config/env")
    public Object getEnviroment(){
        return enviromentConfig;
    }

    @RequestMapping("/config/env2")
    public Object getValue(){
        return name;
    }

}
